import { goodsListData, bannerListData } from './data/goodsData'
/**
 * 商品列表
 */
export const goodsList = {
    url: '/mock/goods/list',
    method: 'get',
    response: config => {
        //get请求参数
        let { pageNo, pageSize } = config.query
        pageNo = pageNo || 1
        pageSize = pageSize || 10
        console.log('pageNo ', pageNo, ' pageSize :', pageSize)
        // 分页
        const startIndex = (pageNo - 1) * pageSize
        const endIndex = pageNo * pageSize
        const list = goodsListData.slice(startIndex, endIndex)
        if(list.length>0){
            return {
                resultCode: 1,
                resultInfo: {
                    list,
                },
            }
        }else{
            return {
                resultCode:-1,
                resultInfo:'没有数据'
            }
        }
    },
}

/**
 *  banner轮播
 */
export const bannerList = {
    url: '/mock/banner',
    method: 'get',
    response: () => {
        return {
            resultCode: 1,
            resultInfo: {
                list: bannerListData,
            },
        }
    },
}
